"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocketClientReqManager = void 0;
const Config_1 = require("../../config/Config");
const ErrorCode_1 = require("../../config/ErrorCode");
const ServerConfig_1 = require("../../config/ServerConfig");
const ProtoServerConfig_1 = require("../socketserver/protocol/ProtoServerConfig");
const Logger_1 = require("../utils/Logger");
const WebSocketClientManager_1 = require("./WebSocketClientManager");
class SocketClientReqManager {
    onSocketMsg(proto_name, data) {
    }
    req_server_login(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_login,
                "account": Config_1.Config.serverType + "-" + ServerConfig_1.ServerConfig.nowServerConfig.id,
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            if (!client.account) {
                Logger_1.Logger.log("req_server_login==", data);
                let respData = yield client.sendDataAsync(data);
                if (respData["code"] == ErrorCode_1.ErrorCode.Code.Suc) {
                    client.account = data["account"];
                }
                Logger_1.Logger.log("req_server_login resp=", respData);
            }
        });
    }
    req_server_set_server_status(status, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_set_server_status,
                "status": status
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            return respData;
        });
    }
    req_server_is_in_server(account, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_is_in_server,
                "account": account
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            Logger_1.Logger.log("req_server_is_in_server==", data);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_is_in_server resp=", respData);
            return respData;
        });
    }
    req_server_is_user_online(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_is_user_online,
                "userid": userid
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            Logger_1.Logger.log("req_server_is_user_online==", data);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_is_user_online resp=", respData);
            return respData;
        });
    }
    req_server_onlie_club(clubid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_onlie_club,
                "clubid": clubid,
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_onlie_club resp=", respData);
            return respData;
        });
    }
    req_server_notify_delete_club_user(clubid, userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_delete_club_user,
                "clubid": clubid,
                "userid": userid
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_notify_delete_club_user resp=", respData);
            return respData;
        });
    }
    req_server_notify_set_club_quanxian(clubid, userid, quanxian, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_set_club_quanxian,
                "clubid": clubid,
                "userid": userid,
                "quanxian": quanxian
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_notify_set_club_quanxian resp=", respData);
            return respData;
        });
    }
    req_server_notify_club_freeze(clubid, userid, user_state, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_club_freeze,
                "clubid": clubid,
                "userid": userid,
                "user_state": user_state
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_notify_club_freeze resp=", respData);
            return respData;
        });
    }
    req_server_notify_set_club_admin(clubid, userid, actor, quanxian, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_set_club_quanxian,
                "clubid": clubid,
                "userid": userid,
                "actor": actor,
                "quanxian": quanxian
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let respData = yield client.sendDataAsync(data);
            Logger_1.Logger.log("req_server_notify_set_club_quanxian resp=", respData);
            return respData;
        });
    }
    req_server_insertRoomTemplateModel(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_insertRoomTemplateModel,
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_deleteRoomTemplateModel(id, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_deleteRoomTemplateModel,
                "id": id,
            };
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_deleteRoom(room_id, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_deleteRoom,
                "room_id": room_id,
            };
            Logger_1.Logger.log("req_server_deleteRoom", data);
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_gems(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_gems,
                "userid": userid,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_coins(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_coins,
                "userid": userid,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_meili(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_meili,
                "userid": userid,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_lv(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_lv,
                "userid": userid,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_invite(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_invite,
                "userid": userid,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
    req_server_notify_update_img(userid, imgurl, upload_pic_type, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let data = {
                "protoName": ProtoServerConfig_1.ProtoServerConfig.req_server_notify_update_img,
                "userid": userid,
                "imgurl": imgurl,
                "upload_pic_type": upload_pic_type,
            };
            // Logger.log("req_server_notify_update_gems", data)
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            client.sendDataAsync(data);
        });
    }
}
exports.SocketClientReqManager = SocketClientReqManager;
SocketClientReqManager.instance = new SocketClientReqManager();
